﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Threading;
using System.Threading.Tasks;
namespace CheatService
{
    /// <summary>
    /// Summary description for EventControl
    /// </summary>
    public static class TaskControl
    {
        private static Timer MessageTaskTimer;
        private static Timer UserTaskTimer;
        public static void StartMessageMaintain()
        {
            if (MessageTaskTimer != null)
            {
                StopMessageMaintain();
            }
            MessageTaskTimer = new Timer(new TimerCallback(delegate(object state)
            {
                MessageControl.RemoveOverTimeMessage();
            }), null, 1000, 2000);
        }

        public static void StopMessageMaintain()
        {
            try
            {
                if (MessageTaskTimer != null)
                {
                    MessageTaskTimer.Dispose();
                }
            }
            catch (Exception ex)
            {
            }
        }

        public static void StartUserMaintain()
        {
            if (UserTaskTimer != null)
            {
                StopUserMaintain();
            }
            UserTaskTimer = new Timer(new TimerCallback(delegate(object state)
            {
                UserContorl.RemoveOfflineUser();
            }), null, 1000, 10000);
        }

        public static void StopUserMaintain()
        {
            try
            {
                if (UserTaskTimer != null)
                {
                    UserTaskTimer.Dispose();
                }
            }
            catch (Exception ex)
            {
            }
        }
    }
}